package org.example.JUC.threadpool;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinWorkerThread;

/**
 * 自定义ForkJoin线程
 */
@Slf4j
public class MyForkJoinWorkerThread extends ForkJoinWorkerThread {
    protected MyForkJoinWorkerThread(ForkJoinPool pool) {
        super(pool);
    }

    /**
     * 线程启动执行
     */
    protected void onStart() {
        log.info("MyForkJoinWorkerThread start");
    }

    /**
     * 结束时异常处理
     * @param exception
     */
    protected void onTermination(Throwable exception) {
        log.info("MyForkJoinWorkerThread end");
        if (exception != null) {
            exception.printStackTrace();
        }
    }

}
